﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace Parlez.LanguageSelectors
{
    public static class LanguageSelectorFactory
    {
        public static LanguageSelector GetLanguageSelector()
        {
            string _SelectorNamespace_String = System.Web.Configuration.WebConfigurationManager.AppSettings.Get("ParlezLanguageSelector");

            if (!String.IsNullOrWhiteSpace(_SelectorNamespace_String))
            {
                var assembly = Assembly.GetExecutingAssembly();

                var type = assembly.GetTypes().First(t => t.Namespace == _SelectorNamespace_String);

                return (LanguageSelector)Activator.CreateInstance(type.GetType());
            }

            return new XMLLanguageSelector();
        }
    }
}
